package org.spring.aicloud.util;

import org.spring.aicloud.entity.detail.SecurityUserDetails;
import org.springframework.security.core.context.SecurityContextHolder;

public class SecurityUtil {
    /**
     * 从Spring Security中得到当前登录对象
     */
    public static SecurityUserDetails getCurrentUser(){
        SecurityUserDetails userDetails = null;
       try {
           userDetails =  (SecurityUserDetails)SecurityContextHolder.
                   getContext().getAuthentication().getPrincipal();
       }catch (Exception e){}
        return userDetails;
    }
}
